<body>
<h1>修改学生</h1>
<form action="update.php" method="post">
    <table>
        <tr>
            <td>姓名：</td>
            <td><input type="text" name="name" require/></td>
        </tr>
        <tr>
            <td>年龄：</td>
            <td><input type="number" name="age" require/></td>
        </tr>
        <tr>
            <td>成绩：</td>
            <td><input type="text" name="score" require/></td>
        </tr>
        <tr>
            <td><button type="submit">修改</button></td>
        </tr>
    </table>
</form>
</body>
</html>

<?php
include'conn.php';
session_start();

if(!$_SESSION['user.account']){

    //print_r($_SESSION['user.account']);
    header('location:login.php');
}

@$id=$_SESSION['user.id'];

@$name=$_POST['name'];
@$age=$_POST['age'];
@$score=$_POST['score'];
$sql="update result set name='$name',result='$score',age=$age where id='$id'";
//echo $sql;
$r=mysqli_query($conn,$sql);
if($r){
    header("location:index.php");
}

@$_SESSION['user.id']=$_GET['id'];

?>
